#include "moyos.h"
#include <QPainter>

Moyos::Moyos(int color)
{
    c = color;
    rect = new QRectF(0,0,15,15);

    setZValue(2);
}

int Moyos::getColor()
{
    return c;
}

QRectF Moyos::boundingRect() const
{
    return *rect;
}

QPainterPath Moyos::shape() const
{
    QPainterPath path;
    path.addRoundRect(*rect, 99, 99);
    return path;
}

void Moyos::paint(QPainter *painter,
               const QStyleOptionGraphicsItem *option, QWidget *widget)
{


    painter->setRenderHint(QPainter::Antialiasing, true);
    if(c == 1)
    {
        painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap));
        painter->setBrush(QBrush(Qt::black, Qt::SolidPattern));
        painter->drawRect(0,0,15,15);
    }
    if(c == -1)
    {
        painter->setPen(QPen(Qt::white, 1, Qt::SolidLine, Qt::SquareCap));
        painter->setBrush(QBrush(Qt::white, Qt::SolidPattern));
        painter->drawRect(0,0,15,15);
    }
}
